package org.westboy.controller;

import de.felixroske.jfxsupport.FXMLController;
import javafx.fxml.FXML;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.westboy.common.base.BaseController;
import org.westboy.common.base.OrderContext;
import org.westboy.model.OrderPro;

@FXMLController
public class DetailController extends BaseController{

    @FXML
    private Label orderId;

    @FXML
    private Label price;

    @FXML
    private Label consignee;

    @FXML
    private Label createTime;

    @FXML
    private Label dec;

    @FXML
    private Label orderNote;

    @FXML
    private TableView tableView;

    @FXML
    private TableColumn picColumn;

    @FXML
    private TableColumn nameColumn;

    @FXML
    private TableColumn numColumn;

    @FXML
    private TableColumn priceColumn;

    @Autowired
    private OrderContext orderContext;

    @Override
    protected void initialize() {
        orderId.textProperty().bind(orderContext.getOrder().orderIdProperty());
        price.textProperty().bind(orderContext.getOrder().priceProperty().asString());
        consignee.textProperty().bind(orderContext.getOrder().consigneeProperty());
        createTime.textProperty().bind(orderContext.getOrder().createTimeProperty());
        dec.textProperty().bind(orderContext.getOrder().desProperty());
        orderNote.textProperty().bind(orderContext.getOrder().orderNoteProperty());
        tableView.itemsProperty().bind(orderContext.listPropertyProperty());
        picColumn.setCellValueFactory(new PropertyValueFactory<>("pic"));
        nameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
        numColumn.setCellValueFactory(new PropertyValueFactory<>("num"));
        priceColumn.setCellValueFactory(new PropertyValueFactory<>("price"));

    }
}
